﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Configuration;
using System.IO;
using System.Threading;
using Oracle.DataAccess.Client;
using System.Net.Sockets;
using System.Net;
using Quartz.JobClass.RequestParmsDTO;
using System.Dynamic;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace Quartz.JobClass
{
    /// <summary>
    /// 数据处理引擎
    /// </summary>
    class CDE_Engine
    {
        static DataTable dt_setting = Platform.Data.OracleHelper.ExecuteDataset(Platform.Configuration.ConfigHelper.BusinessConnString, CommandType.Text, "select * from s_words where belongid=111").Tables[0];
        
        public static string getYonghuXXAll(byte[] result)//01
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();
            
            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int NY = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 6));//Char(2)	年月
                //int pageIndex = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 16, 2));//Char(2)	第N页
                bool getdata = true;
                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString();
                string s_leixing = "YH|" + NY.ToString();
                int pageIndex = 1;
                #endregion
                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01|" + sb.ToString();
                }

                while (getdata)
                {
                    #region 请求Json串
                    DataSet ds_CS = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETLASTMSG;getYonghuXXAll;" + s_leixing + ";" + s_caozuor, "");
                    

                    RequestParms parms = new RequestParms()
                    {
                        parms = new Parms()
                        {
                            Token = _token,
                            YM = NY,
                            Page = pageIndex,
                            errMsg = ds_CS.Tables[0].Rows[0]["errMsg"] != DBNull.Value ? ds_CS.Tables[0].Rows[0]["errMsg"].ToString() : ""
                        }
                    };

                    #endregion
                    string body = Json6Helper.SerializeObject(parms);
                    string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                    string MethodName = ConfigurationManager.AppSettings["getYonghuXXAll"];
                    string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new11.txt",Encoding.Default);//待修改 调接口
                    YonghuXXModel.YonghuXXModel jsonObject = Json6Helper.DeserializeJsonToObject<YonghuXXModel.YonghuXXModel>(resultJson);

                    _SpHelper.Log(s_uuid, "", s_leixing, "getYonghuXXAll", _token, body, jsonObject.errCode, jsonObject.errMsg, s_caozuor, "");

                    if (jsonObject.errCode == "0")
                    {
                        DataTable dt = CommonHelper.ToDataTable<YonghuXXModel.Vals>(jsonObject.vals);
                        dt.TableName = "GSC_YONGHUXX_TMP";
                        CommonHelper.AddStringColumn(dt, "S_UUID", s_uuid);
                        CommonHelper.AddIntColumn(dt, "i_y", NY / 100);
                        CommonHelper.AddIntColumn(dt, "i_m", NY - ((NY / 100) * 100));
                        CommonHelper.AddIntColumn(dt, "I_TYPE", 1);
                        bool _result = _SpHelper.OracleBulkCopy(dt);
                        if (!_result)
                        {
                            sb.Append("操作失败");
                            return "01|" + sb.ToString();
                        }
                    }
                    if (jsonObject.errMsg == "无数据") getdata = false;
                    pageIndex++;
                    Thread.Sleep(5000);
                }
                
                    DataSet ds = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SETYONGHUXX;" + s_uuid + ";" + s_caozuor, "");
                    if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                    {
                        sb.Append("操作成功");
                    }
                    else
                    {
                        LogHelper.Error("GSC_SETYONGHUXX执行错误", ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                        sb.Append("操作失败");
                    }
                
                LogHelper.Info("(SocketService的getYonghuXXAll方法)返回参数：" + sb.ToString());
                return "00|" + sb.ToString();
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的getYonghuXXAll方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                return "01|" + sb.ToString();
            }           
        }

        public static string getYonghuXXMod(byte[] result)
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();
            string returnStr = "";
            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int NY = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 6));//Char(2)	年月
                //int type = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 16, 1));//Char(1)	用户变动类型

                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString();
                string s_leixing = "YH|" + NY.ToString();
                string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                string MethodName = ConfigurationManager.AppSettings["getYonghuXXMod"];

                #endregion

                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败,token值为空");
                    returnStr = "01" + sb.ToString();
                    goto last;
                }

                for (int type = 1; type < 4; type++)
                {
                    #region 请求Json串
                    

                    DataSet ds_CS = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETLASTMSG;getYonghuXXMod;" + s_leixing + ";" + s_caozuor, "");
                    RequestParms parms = new RequestParms()
                    {
                        parms = new Parms()
                        {
                            Token = _token,
                            YM = NY,
                            Type = type,
                            Page=1,
                            errMsg = ds_CS.Tables[0].Rows[0]["errMsg"] != DBNull.Value ? ds_CS.Tables[0].Rows[0]["errMsg"].ToString() : ""
                        }
                    };

                    #endregion
                    string body = Json6Helper.SerializeObject(parms);
                    string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new11.txt",Encoding.Default);//待修改 调接口
                    YonghuXXModel.YonghuXXModel jsonObject = Json6Helper.DeserializeJsonToObject<YonghuXXModel.YonghuXXModel>(resultJson);
                    _SpHelper.Log(s_uuid, "", s_leixing, "getYonghuXXMod", _token, body, jsonObject.errCode, jsonObject.errMsg, s_caozuor, "");

                    if (jsonObject.errCode == "0" && jsonObject.RecCount > 0)
                    {
                        DataTable dt = CommonHelper.ToDataTable<YonghuXXModel.Vals>(jsonObject.vals);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            dt.TableName = "GSC_YONGHUXX_TMP";
                            CommonHelper.AddStringColumn(dt, "S_UUID", s_uuid);
                            CommonHelper.AddIntColumn(dt, "i_y", NY / 100);
                            CommonHelper.AddIntColumn(dt, "i_m", NY - ((NY / 100) * 100));
                            CommonHelper.AddIntColumn(dt, "I_TYPE", type);
                            bool _result = _SpHelper.OracleBulkCopy(dt);
                            //if (_result)
                            //{
                            //    DataSet ds = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SETYONGHUXXMOD;" + s_uuid + ";" + s_caozuor + ";" + type, "");
                            //    if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() != "00|")
                            //    {
                            //        LogHelper.Error("GSC_SETYONGHUXXMOD执行错误", ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                            //        sb.Append("操作失败");
                            //        returnStr = "01|" + sb.ToString();
                            //        goto last;
                            //    }
                            //}
                            //else
                            if (!_result)
                            {
                                sb.Append("操作失败");
                                returnStr = "01|" + sb.ToString();
                                goto last;
                            }
                        }
                        else
                        {

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的getYonghuXXAll方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                returnStr = "01|" + sb.ToString();
                goto last;
            }
            returnStr = "00|" + sb.ToString();
            sb.Append(returnStr);
        last:
            LogHelper.Info("(SocketService的getYonghuXXAll方法)返回参数：" + returnStr);
        return returnStr;
        }
        public static string SelectYonghuXX(byte[] result)//02 插入临时表
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();
            #endregion

            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int NY = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 6));//Char(2)	年月
                string CID = Convert_Helper.GetGb2312String(result, 16, 7);//Char(2)	销根号
                string s_uuid = System.Guid.NewGuid().ToString();  //guid
                SpHelper _SpHelper = new SpHelper();
                string s_leixing = "YH|" + NY.ToString();
                
                #endregion

                #region 请求Json串

                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01" + sb.ToString();
                }

                //DataSet ds_CS = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETLASTMSG;SelectYonghuXX;" + s_leixing + ";" + s_caozuor, "");
                dynamic objmatch = new ExpandoObject();
                //dynamic parms = new ExpandoObject();
                //parms.Add("Token", _token);
                //parms.Add("YongHuH", CID);
                //parms.Add("YM", NY);
                //parms.Add("errMsg", ds_CS.Tables[0].Rows[0]["errMsg"] != DBNull.Value ? ds_CS.Tables[0].Rows[0]["errMsg"].ToString() : "");
                //objmatch.parms = parms;
                //string body = Json6Helper.SerializeObject(objmatch); 

                RequestParms parms = new RequestParms()
                {
                    parms = new Parms()
                    {
                        Token = _token,
                        YongHuH=CID
                        //YM = NY                                           
                    }
                };
                #endregion
                string body = Json6Helper.SerializeObject(parms);
                string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                string MethodName = ConfigurationManager.AppSettings["SelectYonghuXX"];
                string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//string resultJson = File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new11.txt", Encoding.Default);//待修改 调接口
                YonghuXXModel.YonghuXXModel jsonObject = Json6Helper.DeserializeJsonToObject<YonghuXXModel.YonghuXXModel>(resultJson);
                _SpHelper.Log(s_uuid, "", s_leixing, "SelectYonghuXX", _token, body, jsonObject.errCode, jsonObject.errMsg, s_caozuor, "");

                if (jsonObject.errCode == "0")
                {
                    DataTable dt = CommonHelper.ToDataTable<YonghuXXModel.Vals>(jsonObject.vals);
                    dt.TableName = "GSC_YONGHUXX_TMP";
                    CommonHelper.AddStringColumn(dt, "S_UUID", s_uuid);
                    CommonHelper.AddIntColumn(dt, "i_y", NY / 100);
                    CommonHelper.AddIntColumn(dt, "i_m", NY - ((NY / 100) * 100));
                    bool _result = _SpHelper.OracleBulkCopy(dt);
                    if (_result)
                    {
                        DataSet ds = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_BIANGENGSPXXNEW;" + s_uuid + ";" + s_caozuor, "");
                        if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00")
                        {
                            sb.Append("操作成功");
                        }
                        //else
                        //{
                        //    LogHelper.Error("GSC_SETYONGHUXX执行错误", ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                        //    sb.Append("操作失败");
                        //}
                    }
                    else
                    {
                        sb.Append("操作失败");
                        return "01" + sb.ToString();
                    }
                }


                LogHelper.Info("(SocketService的SelectYonghuXX方法)返回参数：" + sb.ToString());

                return "00" + sb.ToString();

            }
            catch (Exception ex)
            {
                LogHelper.Error("SelectYonghuXX发生异常"+ ex.Message);
                return "01" + sb.ToString();
            }
        }
        public static string getHBGXAll(byte[] result)
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();

            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int NY = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 6));//Char(2)	年月
                int pageIndex = 1;// Convert.ToInt32(Convert_Helper.GetGb2312String(result, 16, 2));//Char(2)	第N页
                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString();
                string s_leixing = "HBGX|" + NY.ToString();
                
                bool getdata=true;
                #endregion
                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01" + sb.ToString();
                }

                while (getdata)
                {
                    #region 请求Json串
                    DataSet ds_CS = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETLASTMSG;getHBGXAll;" + s_leixing + ";" + s_caozuor, "");
                    

                    RequestParms parms = new RequestParms()
                    {
                        parms = new Parms()
                        {
                            Token = _token,
                            YM = NY,
                            Page = pageIndex,
                            errMsg = ds_CS.Tables[0].Rows[0]["errMsg"] != DBNull.Value ? ds_CS.Tables[0].Rows[0]["errMsg"].ToString() : ""
                        }
                    };

                    #endregion



                    string body = Json6Helper.SerializeObject(parms);

                    string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                    string MethodName = ConfigurationManager.AppSettings["getHBGXAll"];
                    string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//string resultJson = File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new12.txt", Encoding.Default);//待修改 调接口

                    HBGXMedel.HBGXMedel jsonObject = Json6Helper.DeserializeJsonToObject<HBGXMedel.HBGXMedel>(resultJson);
                    _SpHelper.Log(s_uuid, "", s_leixing, "getHBGXAll", _token, body, jsonObject.errCode, jsonObject.errMsg, s_caozuor, String.Format("TotalCount:{0},RecCount{1}", jsonObject.parms.TotalCount, jsonObject.RecCount));

                    if (jsonObject.errCode == "0" &&jsonObject.RecCount>0)
                    {
                        DataTable dt = CommonHelper.ToDataTable<HBGXMedel.Vals>(jsonObject.vals);
                        dt.TableName = "GSC_HUBIAOXX_TMP";
                        CommonHelper.AddStringColumn(dt, "S_UUID", s_uuid);
                        CommonHelper.AddIntColumn(dt, "i_y", NY / 100);
                        CommonHelper.AddIntColumn(dt, "i_m", NY - ((NY / 100) * 100));
                        CommonHelper.AddIntColumn(dt, "I_TYPE", 1);
                        bool _result = _SpHelper.OracleBulkCopy(dt);
                        if (!_result)
                        {
                            sb.Append("操作失败");
                            return "01|" + sb.ToString();
                        }
                    }
                    if (jsonObject.errMsg=="无数据") getdata = false;
                    pageIndex++;
                    Thread.Sleep(5000);
                }
                DataSet ds = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SETHUBIAOXX;" + s_uuid + ";" + s_caozuor, "");
                if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                {
                    sb.Append("00|操作成功");
                }
                else
                {
                    LogHelper.Error("GSC_SETHUBIAOXX执行错误", ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                    sb.Append("01|操作失败");
                }
                LogHelper.Info("(SocketService的getHBGXAll方法)返回参数：" + sb.ToString());
                return  sb.ToString();
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的getHBGXAll方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                return "01" + sb.ToString();
            }  
        }

        public static string getHBGXMod(byte[] result)
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();
            string returnStr = "";
            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int NY = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 6));//Char(2)	年月
                //int type = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 16, 1));//Char(1)	用户变动类型

                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString();
                string s_leixing = "HBGX|" + NY.ToString();
                string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                string MethodName = ConfigurationManager.AppSettings["getHBGXMod"];

                #endregion

                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败,token值为空");
                    returnStr = "01" + sb.ToString();
                    goto last;
                }

                for (int type = 1; type < 3; type++)
                {
                    #region 请求Json串
                    

                    DataSet ds_CS = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETLASTMSG;getHBGXMod;" + s_leixing + ";" + s_caozuor, "");
                    RequestParms parms = new RequestParms()
                    {
                        parms = new Parms()
                        {
                            Token = _token,
                            YM = NY,
                            Type = type,
                            Page=1,
                            errMsg = ds_CS.Tables[0].Rows[0]["errMsg"] != DBNull.Value ? ds_CS.Tables[0].Rows[0]["errMsg"].ToString() : ""
                        }
                    };

                    #endregion
                    string body = Json6Helper.SerializeObject(parms);
                    string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new11.txt",Encoding.Default);//待修改 调接口
                    //YonghuXXModel.YonghuXXModel jsonObject = Json6Helper.DeserializeJsonToObject<YonghuXXModel.YonghuXXModel>(resultJson);
                    HBGXMedel.HBGXMedel jsonObject = Json6Helper.DeserializeJsonToObject<HBGXMedel.HBGXMedel>(resultJson);
                    _SpHelper.Log(s_uuid, "", s_leixing, "getHBGXMod", _token, body, jsonObject.errCode, jsonObject.errMsg, s_caozuor, String.Format("RecCount{0}", jsonObject.RecCount));

                    if (jsonObject.errCode == "0" && jsonObject.RecCount > 0)
                    {
                        DataTable dt = CommonHelper.ToDataTable<HBGXMedel.Vals>(jsonObject.vals);
                        //DataTable dt = CommonHelper.ToDataTable<YonghuXXModel.Vals>(jsonObject.vals);
                        dt.TableName = "GSC_HUBIAOXX_TMP";
                        CommonHelper.AddStringColumn(dt, "S_UUID", s_uuid);
                        CommonHelper.AddIntColumn(dt, "i_y", NY / 100);
                        CommonHelper.AddIntColumn(dt, "i_m", NY - ((NY / 100) * 100));
                        CommonHelper.AddIntColumn(dt, "I_TYPE", type);
                        bool _result = _SpHelper.OracleBulkCopy(dt);

                        //if (_result)
                        //{
                        //    DataSet ds = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SETHUBIAOXXMOD;" + s_uuid + ";" + s_caozuor + ";" + type, "");
                        //    if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                        //    {
                        //        sb.Append("操作成功");
                        //    }
                        //    else
                        //    {
                        //        LogHelper.Error("GSC_SETHUBIAOXXMOD执行错误", ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                        //        sb.Append("操作失败");
                        //        returnStr = "01" + sb.ToString();
                        //        goto last;
                        //    }
                        //}
                        //else
                        if (!_result)
                        {
                            sb.Append("操作失败");
                            returnStr = "01" + sb.ToString();
                            goto last;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的getHBGXMod方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                returnStr = "01" + sb.ToString();
                goto last;
            }
            returnStr = "00" + sb.ToString();
        last:
            LogHelper.Info("(SocketService的getHBGXMod方法)返回参数：" + returnStr);
        return returnStr;
        }
        /// <summary>
        /// 获取定额数据 由供水企业读取，获取指定年份全部的源定额数据
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public static string getYuanDingE(byte[] result)
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();

            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int year = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 4));//Char(4)	年
                int pageIndex = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 14, 2));//Char(2)	第N页
                string s_leixing="YDE|"+year.ToString();
                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString();
                #endregion

                #region 请求Json串

                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01" + sb.ToString();
                }
                DataSet ds_CS = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETLASTMSG;getYuanDingE;" + s_leixing + ";" + s_caozuor, "");
                RequestParms parms = new RequestParms()
                {
                    parms = new Parms()
                    {
                        Token = _token,
                        Year=year,
                        Page = pageIndex,
                        errMsg = ds_CS.Tables[0].Rows[0]["errMsg"] != DBNull.Value ? ds_CS.Tables[0].Rows[0]["errMsg"].ToString() : ""
                    }
                };

                #endregion



                string body = Json6Helper.SerializeObject(parms);

                string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                string MethodName = ConfigurationManager.AppSettings["getYuanDingE"];
                string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);
                //string resultJson = File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new12.txt", Encoding.Default);//待修改 调接口

                YuanDingEModel.YuanDingEModel jsonObject = Json6Helper.DeserializeJsonToObject<YuanDingEModel.YuanDingEModel>(resultJson);
                //HBGXMedel.HBGXMedel jsonObject = Json6Helper.DeserializeJsonToObject<HBGXMedel.HBGXMedel>(resultJson);
                _SpHelper.Log(s_uuid, "",s_leixing , "getYuanDingE", _token, body, jsonObject.errCode, jsonObject.errMsg, s_caozuor, "");

                if (jsonObject.errCode == "0")
                {
                    DataTable dt = CommonHelper.ToDataTable<YuanDingEModel.Vals>(jsonObject.vals);
                    foreach (DataColumn item in dt.Columns)
                        item.ColumnName = item.ColumnName.ToUpper();
                    dt.TableName = "GSC_DINGESL_TMP";
                    CommonHelper.AddStringColumn(dt, "S_UUID", s_uuid);
                    //CommonHelper.AddIntColumn(dt, "i_y", year);
                    bool _result = _SpHelper.OracleBulkCopy(dt);
                    if (_result)
                    {
                        DataSet ds = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SETDINGESL;" + s_uuid + ";" + s_caozuor, "");
                        if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                        {
                            sb.Append("操作成功");
                        }
                        else
                        {
                            LogHelper.Error("GSC_SETDINGESL执行错误", ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                            sb.Append("操作失败");
                        }
                    }
                    else
                    {
                        sb.Append("操作失败");
                        return "01" + sb.ToString();
                    }
                }


                LogHelper.Info("(SocketService的getYuanDingE方法)返回参数：" + sb.ToString());

                return "00" + sb.ToString();
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的getYuanDingE方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                return "01" + sb.ToString();
            }
        }
        /// <summary>
        /// 超定额水量获取
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public static string getChaoDingE(byte[] result)
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();

            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int year = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 4));//Char(4)	年
                int jidu = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 14, 1));//Char(1)	季度
                //int pageIndex = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 15, 2));//Char(2)	第N页
                string s_leixing = "CDE|" + year.ToString()+jidu.ToString();
                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString();
                #endregion

                #region 请求Json串

                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01" + sb.ToString();
                }
                DataSet ds_CS = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETLASTMSG;getChaoDingE;" + s_leixing + ";" + s_caozuor, "");
                RequestParms parms = new RequestParms()
                {
                    parms = new Parms()
                    {
                        Token = _token,
                        Year = year,
                        JiDu=jidu,
                        errMsg = ds_CS.Tables[0].Rows[0]["errMsg"] != DBNull.Value ? ds_CS.Tables[0].Rows[0]["errMsg"].ToString() : ""//需传入
                    }
                };

                #endregion



                string body = Json6Helper.SerializeObject(parms);

                string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                string MethodName = ConfigurationManager.AppSettings["getChaoDingE"];
                string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//string resultJson = File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new12.txt", Encoding.Default);//待修改 调接口


                ChaoDingEModel.ChaoDingEModel jsonObject = Json6Helper.DeserializeJsonToObject<ChaoDingEModel.ChaoDingEModel>(resultJson);
                //HBGXMedel.HBGXMedel jsonObject = Json6Helper.DeserializeJsonToObject<HBGXMedel.HBGXMedel>(resultJson);
                _SpHelper.Log(s_uuid, "", s_leixing, "getChaoDingE", _token, body, jsonObject.errCode, jsonObject.errMsg, s_caozuor, "");

                if (jsonObject.errCode == "0")
                {
                    DataTable dt = CommonHelper.ToDataTable<ChaoDingEModel.Vals>(jsonObject.vals);
                    dt.TableName = "GSC_CHAOBIAOSJ_TMP";
                    CommonHelper.AddStringColumn(dt, "S_UUID", s_uuid);
                    //CommonHelper.AddIntColumn(dt, "i_y", year);
                    bool _result = _SpHelper.OracleBulkCopy(dt);
                    if (_result)
                    {
                        DataSet ds = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SETCHAOBIAOSJ;" + s_uuid + ";" + s_caozuor, "");
                        if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                        {
                            sb.Append("操作成功");
                        }
                        else
                        {
                            LogHelper.Error("GSC_SETCHAOBIAOSJ执行错误", ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                            sb.Append("操作失败");
                        }
                    }
                    else
                    {
                        sb.Append("操作失败");
                        return "01" + sb.ToString();
                    }
                }


                LogHelper.Info("(SocketService的getChaoDingE方法)返回参数：" + sb.ToString());

                return "00" + sb.ToString();
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的getChaoDingE方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                return "01" + sb.ToString();
            }
        }
        /// <summary>
        /// 由供水企业调用，将水表的抄表数据推送给供水处。
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public static string PumpChaoBiaoSJ(byte[] result)
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();

            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int NY = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 6));//Char(4)	年
                int pageIndex = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 16, 2));//Char(2)	第N页
                string s_leixing = "CBSJ|" + NY.ToString();
                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString();
                #endregion

                #region 请求Json串

                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01" + sb.ToString();
                }

                //DataSet ds_CS = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETLASTMSG;SelectYonghuXX;" + s_leixing + ";" + s_caozuor, "");
                DataSet ds_cbsj = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_ZWCHAOBIAOSJ;" + NY + ";" + pageIndex, "");//GSC_ZWCHAOBIAOSJ

                string JsonString = string.Empty;
                if (ds_cbsj.Tables[0].Rows.Count > 0)
                {
                    JsonString = Newtonsoft.Json.JsonConvert.SerializeObject(ds_cbsj.Tables[0]);
                }

                Quartz.JobClass.ChaoBiaoSJModel.ChaoBiaoSJModel _parms = new ChaoBiaoSJModel.ChaoBiaoSJModel()
                {
                    parms = new ChaoBiaoSJModel.Parms()
                    {
                        Token = _token,
                        YM = NY.ToString(),
                        Page = pageIndex.ToString(),
                        RecCount = ds_cbsj.Tables[0].Rows.Count.ToString(),
                        TotalCount = ds_cbsj.Tables[0].Rows[0]["TotalCount"].ToString(),
                        IsComplete = ds_cbsj.Tables[0].Rows[0]["IsComplete"].ToString()
                    },

                    vals = CommonHelper.TableConvertList<ChaoBiaoSJModel.Vals>(ds_cbsj.Tables[0], new ChaoBiaoSJModel.Vals())
                };
                string body = Json6Helper.SerializeObject(_parms);

                #endregion

                string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                string MethodName = ConfigurationManager.AppSettings["PumpChaoBiaoSJ"];
                string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//string resultJson = File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new11.txt", Encoding.Default);//待修改 调接口

                JObject jsonObject = (JObject)JsonConvert.DeserializeObject(resultJson);
                _SpHelper.Log(s_uuid, "", s_leixing, "PumpChaoBiaoSJ", _token, Json6Helper.SerializeObject(_parms.parms), jsonObject["errCode"].ToString(), jsonObject["errMsg"].ToString(), s_caozuor, "");
                //_SpHelper.Log(s_uuid, "", s_leixing, "PumpChaoBiaoSJ", _token, "", "", "", s_caozuor,  Json6Helper.SerializeObject(_parms.parms)+"--->返回：" + resultJson);
                if (jsonObject["errCode"].ToString() == "0")
                {
                    sb.Append("操作成功");
                }
                else
                {
                    sb.Append("操作失败" + jsonObject["errMsg"].ToString());
                    LogHelper.Info("(SocketService的PumpChaoBiaoSJ方法)返回参数：" + sb.ToString());
                    return "01" + sb.ToString();
                }
                LogHelper.Info("(SocketService的PumpChaoBiaoSJ方法)返回参数：" + sb.ToString());
                return "00" + sb.ToString();
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的PumpChaoBiaoSJ方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                return "01" + sb.ToString();
            }
        }
        public static string PumpChaoBiaoSJALL(int NY)
        {
            string sendmessage = "";
            try
            {

                //int NY = 202009;
                SpHelper _SpHelper = new SpHelper();
                for (int i = 0; i < 100; i++)
                {
                    DataSet ds_cbsj = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_ZWCHAOBIAOSJ;" + NY.ToString() + ";" + (i + 1).ToString(), "");
                    if (ds_cbsj.Tables[0].Rows.Count > 0)
                    {
                        Thread.Sleep(10000);
                        string str = "csmsgd|331" + NY.ToString() + (i + 1).ToString().PadLeft(2, '0');
                        LogHelper.Info("开始处理：" + str);
                        byte[] byteArray = System.Text.Encoding.Default.GetBytes(str);
                        sendmessage = sendmessage + CDE_Engine.PumpChaoBiaoSJ(byteArray);
                    }
                }

            }
            catch (Exception ex)
            {
                LogHelper.Info("数据生成异常" + ex.Message);
            }
            return sendmessage;
        }

        public static string SelectDETZD(byte[] result)//01
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();

            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int year = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 4));//Char(4)	年

                bool getdata = true;
                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString();
                string s_leixing = "YDE|" + year.ToString();

                int pageIndex = 1;
                #endregion
                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01|" + sb.ToString();
                }

                //while (getdata)
                //{
                    #region 请求Json串


                    RequestParms parms = new RequestParms()
                    {
                        parms = new Parms()
                        {
                            Token = _token,
                            Year = year
                        }
                    };

                    #endregion
                    string body = Json6Helper.SerializeObject(parms);



                    string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                    string MethodName = "api/jk/de_tzd.kc?act=SelectDETZD";
                    string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//string resultJson = File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new11.txt", Encoding.Default);//待修改 调接口



                    DETZDModel.DETZDModel jsonObject = Json6Helper.DeserializeJsonToObject<DETZDModel.DETZDModel>(resultJson);

                    _SpHelper.Log(s_uuid, "", s_leixing, "SelectDETZD", _token, body, jsonObject.errCode, jsonObject.errMsg, s_caozuor, "");

                    if (jsonObject.errCode == "0")
                    {
                        DataTable dt = CommonHelper.ToDataTable<DETZDModel.Vals>(jsonObject.vals);
                        dt.TableName = "QuotaNotice";
                        CommonHelper.AddStringColumn(dt, "ID", s_uuid);
                        CommonHelper.AddStringColumn(dt, "OPERATOR", s_caozuor);
                        CommonHelper.AddStringColumn(dt, "OPERATINGTIME", "");

                        //特殊处理，datatable的列位置必须与数据表的列位置保持一致
                        dt.Columns["I_YSL"].SetOrdinal(36);
                        dt.Columns["I_FWLX"].SetOrdinal(36);

                        bool _result = _SpHelper.OracleBulkCopy(dt);
                        if (!_result)
                        {
                            sb.Append("操作失败");
                            return "01|" + sb.ToString();
                        }
                        else
                        {
                            sb.Append("操作成功");
                        }
                    }
                    if (jsonObject.errMsg == "无数据") getdata = false;
                    pageIndex++;
                    Thread.Sleep(5000);
                //}

                //DataSet ds = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SelectDETZD;" + s_uuid + ";" + s_caozuor, "");
                //if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                //{
                //    sb.Append("操作成功");
                //}
                //else
                //{
                //    LogHelper.Error("GSC_SelectDETZD执行错误", ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                //    sb.Append("操作失败");
                //}

                //LogHelper.Info("(SocketService的SelectDETZD方法)返回参数：" + sb.ToString());
                return "00|" + sb.ToString();
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的SelectDETZD方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                return "01|" + sb.ToString();
            }
        }
        public static string SelectCDETZD(byte[] result)//01
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();

            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码

                int year = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 4));//Char(4)	年
                int jidu = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 14, 1));//Char(1)	季度

                string s_leixing = "CDE|" + year.ToString() + jidu.ToString();
                bool getdata = true;
                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString();

                int pageIndex = 1;
                #endregion
                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01|" + sb.ToString();
                }

                //while (getdata)
                //{
                    #region 请求Json串


                    RequestParms parms = new RequestParms()
                    {
                        parms = new Parms()
                        {
                            Token = _token,
                            Year = year,
                            JiDu = jidu
                        }
                    };

                    #endregion
                    string body = Json6Helper.SerializeObject(parms);



                    string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                    string MethodName = "api/jk/de_tzd.kc?act=SelectCDETZD";
                    string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//string resultJson = File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new11.txt", Encoding.Default);//待修改 调接口



                    CDETZDModel.CDETZDModel jsonObject = Json6Helper.DeserializeJsonToObject<CDETZDModel.CDETZDModel>(resultJson);

                    _SpHelper.Log(s_uuid, "", s_leixing, "SelectCDETZD", _token, body, jsonObject.errCode, jsonObject.errMsg, s_caozuor, "");

                    if (jsonObject.errCode == "0")
                    {
                        DataTable dt = CommonHelper.ToDataTable<CDETZDModel.Vals>(jsonObject.vals);
                        dt.TableName = "OverQuotaNotice";
                        CommonHelper.AddStringColumn(dt, "ID", s_uuid);
                        CommonHelper.AddStringColumn(dt, "OPERATOR", s_caozuor);
                        CommonHelper.AddStringColumn(dt, "OPERATINGTIME", "");
                        //CommonHelper.AddIntColumn(dt, "i_y", year);
                        bool _result = _SpHelper.OracleBulkCopy(dt);
                        if (!_result)
                        {
                            sb.Append("操作失败");
                            return "01|" + sb.ToString();
                        }
                        else
                        {
                            sb.Append("操作成功");
                        }
                    }
                    if (jsonObject.errMsg == "无数据") getdata = false;
                    pageIndex++;
                    Thread.Sleep(5000);
                //}

                //DataSet ds = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SelectCDETZD;" + s_uuid + ";" + s_caozuor, "");
                //if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                //{
                //    sb.Append("操作成功");
                //}
                //else
                //{
                //    LogHelper.Error("GSC_SelectCDETZD执行错误", ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                //    sb.Append("操作失败");
                //}

                //LogHelper.Info("(SocketService的SelectCDETZD方法)返回参数：" + sb.ToString());
                return "00|" + sb.ToString();
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的SelectCDETZD方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                return "01|" + sb.ToString();
            }
        }
        public static string SelectCDEFHTZD(byte[] result)//01
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();

            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码

                int year = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 4));//Char(4)	年
                int jidu = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 14, 1));//Char(1)	季度

                string s_leixing = "CDE|" + year.ToString() + jidu.ToString();
                bool getdata = true;
                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString();

                int pageIndex = 1;
                #endregion
                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01|" + sb.ToString();
                }

                //while (getdata)
                //{
                    #region 请求Json串


                    RequestParms parms = new RequestParms()
                    {
                        parms = new Parms()
                        {
                            Token = _token,
                            Year = year,
                            JiDu = jidu
                        }
                    };

                    #endregion
                    string body = Json6Helper.SerializeObject(parms);



                    string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                    string MethodName = "api/jk/de_tzd.kc?act=SelectCDEFHTZD";
                    string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//string resultJson = File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new11.txt", Encoding.Default);//待修改 调接口



                    SelectCDEFHTZDModel.SelectCDEFHTZDModel jsonObject = Json6Helper.DeserializeJsonToObject<SelectCDEFHTZDModel.SelectCDEFHTZDModel>(resultJson);

                    _SpHelper.Log(s_uuid, "", s_leixing, "SelectCDEFHTZD", _token, body, jsonObject.errCode, jsonObject.errMsg, s_caozuor, "");

                    if (jsonObject.errCode == "0")
                    {
                        DataTable dt = CommonHelper.ToDataTable<SelectCDEFHTZDModel.Vals>(jsonObject.vals);
                        dt.TableName = "ExcessQuotaReviewNotice";
                        CommonHelper.AddStringColumn(dt, "ID", s_uuid);
                        bool _result = _SpHelper.OracleBulkCopy(dt);
                        if (!_result)
                        {
                            sb.Append("操作失败");
                            return "01|" + sb.ToString();
                        }
                        else
                        {
                            sb.Append("操作成功");
                        }
                    }
                    if (jsonObject.errMsg == "无数据") getdata = false;
                    pageIndex++;
                    Thread.Sleep(5000);
                //}

                //DataSet ds = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SelectCDEFHTZD;" + s_uuid + ";" + s_caozuor, "");
                //if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                //{
                //    sb.Append("操作成功");
                //}
                //else
                //{
                //    LogHelper.Error("GSC_SelectCDEFHTZD执行错误", ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                //    sb.Append("操作失败");
                //}

                //LogHelper.Info("(SocketService的SelectCDEFHTZD方法)返回参数：" + sb.ToString());
                return "00|" + sb.ToString();
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的SelectCDEFHTZD方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                return "01|" + sb.ToString();
            }
        }

        public static string PumpKaiZhangSF(byte[] result)
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();

            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int year = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 4));//Char(4)	年
                int jidu = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 14, 1));//Char(1)	季度
                string s_leixing = "CDE|" + year.ToString() + jidu.ToString();
                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString("N");
                #endregion

                #region 请求Json串

                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01|" + sb.ToString();
                }

                //DataSet ds_CS = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETLASTMSG;SelectYonghuXX;" + s_leixing + ";" + s_caozuor, "");
                DataSet ds_cbsj = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETDAIKAIZHANGSF;" + year + ";" + jidu + "", "");//GSC_ZWCHAOBIAOSJ

                string JsonString = string.Empty;
                if (ds_cbsj.Tables[0].Rows.Count > 0)
                {
                    JsonString = Newtonsoft.Json.JsonConvert.SerializeObject(ds_cbsj.Tables[0]);
                }
                else
                {
                    sb.Append("操作失败!无开账数据可推送！");
                    LogHelper.Info("(SocketService的PumpKaiZhangSJ方法)内部异常：" + sb.ToString());
                    return "01|" + sb.ToString();
                }

                Quartz.JobClass.ShouFeiSJModel.ShouFeiSJModel _parms = new ShouFeiSJModel.ShouFeiSJModel()
                {
                    parms = new ShouFeiSJModel.parms()
                    {
                        Token = _token,
                        RecCount = ds_cbsj.Tables[0].Rows.Count
                    },

                    vals = CommonHelper.TableConvertList<ShouFeiSJModel.vals>(ds_cbsj.Tables[0], new ShouFeiSJModel.vals())
                };
                string body = Json6Helper.SerializeObject(_parms);

                #endregion

                string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                string MethodName = "api/jk/zlsgs_kz.kc?act=PumpShouFeiSJ";
                string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//string resultJson = File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new11.txt", Encoding.Default);//待修改 调接口

                JObject jsonObject = (JObject)JsonConvert.DeserializeObject(resultJson);
                _SpHelper.Log(s_uuid, "", s_leixing, "PumpShoufeiSJ", _token, Json6Helper.SerializeObject(_parms.parms), jsonObject["errCode"].ToString(), jsonObject["errMsg"].ToString(), s_caozuor, "");
                //_SpHelper.Log(s_uuid, "", s_leixing, "PumpChaoBiaoSJ", _token, "", "", "", s_caozuor,  Json6Helper.SerializeObject(_parms.parms)+"--->返回：" + resultJson);
                if (jsonObject["errCode"].ToString() == "0")
                {
                    //string strParms = "";
                    //strParms += year + ";";//V_YEAR            INTEGER,
                    //strParms += jidu + ";";//V_JIDU            INTEGER,
                    //strParms += s_caozuor + ";";//V_CAOZUOR         VARCHAR2,
                    //strParms += s_uuid + ";";//V_UUID_NEW        VARCHAR2,
                    //strParms += "1" + ";";//V_JLZT            VARCHAR2, //0初始数据，1已推送，2已核对，3已开账数据
                    //ds_cbsj = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SETKAIZHANGSJ;" + strParms, "");
                    //if (ds_cbsj.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                    //{
                    //    sb.Append("操作成功");
                    //}
                    //else
                    //{
                    //    sb.Append("操作失败" + ds_cbsj.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                    //    LogHelper.Info("(SocketService的PumpKaiZhangSJ方法)内部异常：" + sb.ToString());
                    //    return "01|" + sb.ToString();
                    //}
                }
                else
                {
                    sb.Append("操作失败" + jsonObject["errMsg"].ToString());
                    LogHelper.Info("(SocketService的PumpKaiZhangSJ方法)返回参数：" + sb.ToString());
                    return "01|" + sb.ToString();
                }
                LogHelper.Info("(SocketService的PumpKaiZhangSJ方法)返回参数：" + sb.ToString());
                return "00|" + sb.ToString();
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的PumpKaiZhangSJ方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                return "01|" + sb.ToString();
            }
        }
        public static string PumpKaiZhangSJ(byte[] result)
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();

            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int year = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 4));//Char(4)	年
                int jidu = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 14, 1));//Char(1)	季度
                string s_leixing = "CDE|" + year.ToString() + jidu.ToString();
                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString("N");
                #endregion

                #region 请求Json串

                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01|" + sb.ToString();
                }

                //DataSet ds_CS = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETLASTMSG;SelectYonghuXX;" + s_leixing + ";" + s_caozuor, "");
                DataSet ds_cbsj = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETDAIKAIZHANGSJ;"+year+";" + jidu + "", "");//GSC_ZWCHAOBIAOSJ

                string JsonString = string.Empty;
                if (ds_cbsj.Tables[0].Rows.Count > 0)
                {
                    JsonString = Newtonsoft.Json.JsonConvert.SerializeObject(ds_cbsj.Tables[0]);
                }
                else
                {
                    sb.Append("操作失败!无开账数据可推送！");
                    LogHelper.Info("(SocketService的PumpKaiZhangSJ方法)内部异常：" + sb.ToString());
                    return "01|" + sb.ToString();
                }

                Quartz.JobClass.KaiZhangSJModel.KaiZhangSJModel _parms = new KaiZhangSJModel.KaiZhangSJModel()
                {
                    parms = new KaiZhangSJModel.parms()
                    {
                        Token = _token,
                        Year=year,
                        JiDu=jidu,
                        RecCount = ds_cbsj.Tables[0].Rows.Count
                    },

                    vals = CommonHelper.TableConvertList<KaiZhangSJModel.vals>(ds_cbsj.Tables[0], new KaiZhangSJModel.vals())
                };
                string body = Json6Helper.SerializeObject(_parms);

                #endregion

                string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                string MethodName = ConfigurationManager.AppSettings["PumpKaiZhangSJ"];
                string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//string resultJson = File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new11.txt", Encoding.Default);//待修改 调接口

                JObject jsonObject = (JObject)JsonConvert.DeserializeObject(resultJson);
                _SpHelper.Log(s_uuid, "", s_leixing, "PumpKaiZhangSJ", _token, Json6Helper.SerializeObject(_parms.parms), jsonObject["errCode"].ToString(), jsonObject["errMsg"].ToString(), s_caozuor, "");
                //_SpHelper.Log(s_uuid, "", s_leixing, "PumpChaoBiaoSJ", _token, "", "", "", s_caozuor,  Json6Helper.SerializeObject(_parms.parms)+"--->返回：" + resultJson);
                if (jsonObject["errCode"].ToString() == "0")
                {
                    string strParms = "";
                    strParms += year+";";//V_YEAR            INTEGER,
                    strParms += jidu + ";";//V_JIDU            INTEGER,
                    strParms += s_caozuor + ";";//V_CAOZUOR         VARCHAR2,
                    strParms += s_uuid + ";";//V_UUID_NEW        VARCHAR2,
                    strParms += "1" + ";";//V_JLZT            VARCHAR2, //0初始数据，1已推送，2已核对，3已开账数据
                    ds_cbsj=_SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SETKAIZHANGSJ;" + strParms, "");
                    if (ds_cbsj.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                    {
                        sb.Append("操作成功");
                    }
                    else
                    {
                        sb.Append("操作失败" + ds_cbsj.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                        LogHelper.Info("(SocketService的PumpKaiZhangSJ方法)内部异常：" + sb.ToString());
                        return "01|" + sb.ToString();
                    }
                }
                else
                {
                    sb.Append("操作失败" + jsonObject["errMsg"].ToString());
                    LogHelper.Info("(SocketService的PumpKaiZhangSJ方法)返回参数：" + sb.ToString());
                    return "01|" + sb.ToString();
                }
                LogHelper.Info("(SocketService的PumpKaiZhangSJ方法)返回参数：" + sb.ToString());
                return "00|" + sb.ToString();
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的PumpKaiZhangSJ方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                return "01|" + sb.ToString();
            }
        }

        public static string getKaiZhangError(byte[] result)
        {
            #region 设置获取的查询值
            StringBuilder sb = new StringBuilder();

            #endregion
            try
            {
                #region 获取查询值
                string s_caozuor = Convert_Helper.GetGb2312String(result, 0, 6);//Char(6)	操作人
                string TRAN_CODE = Convert_Helper.GetGb2312String(result, 7, 3);//Char(2)	交易码
                int year = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 10, 4));//Char(4)	年
                int jidu = Convert.ToInt32(Convert_Helper.GetGb2312String(result, 14, 1));//Char(1)	季度
                string s_leixing = "CDE|" + year.ToString() + jidu.ToString();
                SpHelper _SpHelper = new SpHelper();
                string s_uuid = System.Guid.NewGuid().ToString();
                #endregion

                #region 请求Json串

                string _token = CommonHelper.GetToken();
                if (_token == "")
                {
                    sb.Append("操作失败");
                    return "01" + sb.ToString();
                }
                //DataSet ds_CS = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_GETLASTMSG;KaiZhangError;" + s_leixing + ";" + s_caozuor, "");
                RequestParms parms = new RequestParms()
                {
                    parms = new Parms()
                    {
                        Token = _token,
                        Year = year,
                        JiDu = jidu
                    }
                };

                #endregion
                
                string body = Json6Helper.SerializeObject(parms);

                string postUrl = dt_setting.Select("WORDSCONTENT='GSC_Url'")[0]["WORDSVALUE"].ToString();
                string MethodName = ConfigurationManager.AppSettings["SelectKaiZhangError"];
                string resultJson = CommonHelper.QueryPostWebService(postUrl, MethodName, body);//string resultJson = File.ReadAllText(@"D:\A_WorkSpace\pudongveolia\CSMS外部接口\非居累计加价\new12.txt", Encoding.Default);//待修改 调接口


                KaiZhangErrorModel.KaiZhangErrorModel jsonObject = Json6Helper.DeserializeJsonToObject<KaiZhangErrorModel.KaiZhangErrorModel>(resultJson);
                //HBGXMedel.HBGXMedel jsonObject = Json6Helper.DeserializeJsonToObject<HBGXMedel.HBGXMedel>(resultJson);
                _SpHelper.Log(s_uuid, "", s_leixing, "getKaiZhangError", _token, body, jsonObject.errCode, jsonObject.errMsg, s_caozuor, "");

                if (jsonObject.errCode != "0")
                {
                    DataTable dt = CommonHelper.ToDataTable<KaiZhangErrorModel.ValsItem>(jsonObject.vals);
                    dt.TableName = "GSC_WAIFUXX_TMP";
                    CommonHelper.AddStringColumn(dt, "S_UUID", s_uuid);
                    //CommonHelper.AddIntColumn(dt, "i_y", year);
                    bool _result = _SpHelper.OracleBulkCopy(dt);
                    if(!_result)
                    //if (_result)
                    //{
                        
                    //}
                    //else
                    {
                        sb.Append("操作失败");
                        return "01" + sb.ToString();
                    }
                }
                DataSet ds = _SpHelper.GetParamsDataSource("<PROCEDURE>", "INSERT;GSC_SETKAIZHANGJG;" + s_uuid + ";" +year+ ";" +jidu+ ";" + s_caozuor, "");
                if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() == "00|")
                {
                    sb.Append("操作成功");
                }
                else
                {
                    LogHelper.Error("GSC_SETKAIZHANGJG执行错误", ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1]);
                    sb.Append("操作失败");
                }

                LogHelper.Info("(SocketService的getKaiZhangError方法)返回参数：" + sb.ToString());

                return "00" + sb.ToString();
            }
            catch (Exception ex)
            {
                LogHelper.Error("(SocketService的getKaiZhangError方法)发生异常：" + ex.Message);
                sb.Append("操作失败");
                return "01" + sb.ToString();
            }
        }
    }
}